// components/activity-stats/index.js
import componentBehavior from '../../../behaviors/component';
import { COMPONENT_OPTIONS } from '../../../constants/common';
import { isEmpty } from '../../../common/utils'

Component({
    behaviors: [componentBehavior],
    options: {
        ...COMPONENT_OPTIONS,
    },
    properties: {
        type: {
            type: String,
            value: 'all', // all || self || help  
        },
        showDistributeStats: {
            type: Boolean,
            value: false,
        },
        statsInfo: {
            type: Object,
            value: {},
        },
    },
    observers: {
        'statsInfo': function (val) {
            if (val && !isEmpty(val)) {
                const info = {};
                for(let i in val) {
                    info[i] = i !== 'orderCount' ? `${val[i] < 0 ? '-' : ''}¥${Math.abs(val[i]) / 100}` : val[i];
                }
                this.setData({ info });
            }
        },
    },
    data: {
        info: {},
    },
    methods: {
    }
})
